using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// A region contains a bounding box (LatLonAltBox) that describes an area of interest defined by geographic 
    /// coordinates and altitudes. In addition, a Region contains an LOD (level of detail) extent (Lod) 
    /// that defines a validity range of the associated Region in terms of projected screen size. 
    /// A Region is said to be "active" when the bounding box is within the user's view and the LOD 
    /// requirements are met. Objects associated with a Region are drawn only when the Region is active. 
    /// When the viewRefreshMode is onRegion, the Link or Icon is loaded only when the Region is active. 
    /// See the KML 2.1 Tutorial for more details. In a Container or NetworkLink hierarchy, this calculation 
    /// uses the Region that is the closest ancestor in the hierarchy. 
    /// </summary>
    public class KmlRegion : IKmlElement
    {
        private string tagName = "Region";

        #region LatLonAtlBox
        private KmlLatLonAltBox latLonAtlBox = new KmlLatLonAltBox();

        /// <summary>
        /// A bounding box that describes an area of interest defined by geographic coordinates and altitudes.
        /// </summary>
        /// <value>The bounding box.</value>
        public KmlLatLonAltBox LatLonAtlBox
        {
            get { return latLonAtlBox; }
            set { latLonAtlBox = value; }
        } 
        #endregion

        #region Lod
        private KmlLod lod = new KmlLod();

        /// <summary>
        /// Lod is an abbreviation for Level of Detail. Lod describes the size of the projected 
        /// region on the screen that is required in order for the region to be considered "active." 
        /// Also specifies the size of the pixel ramp used for fading in (from transparent to opaque) 
        /// and fading out (from opaque to transparent). 
        /// </summary>
        /// <value>The lod.</value>
        public KmlLod Lod
        {
            get { return lod; }
            set { lod = value; }
        } 
        #endregion

        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return this.tagName; }
        }

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(this.tagName);
            this.latLonAtlBox.GenerateKml(writer);
            this.lod.GenerateKml(writer);
            writer.WriteFullEndElement();
        }

        #endregion
    }
}
